<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul{
            margin: 0;
        }
        li{
            list-style: none;
        }
        .f1{
            padding-bottom: 15px;
            margin-bottom: 15px;
            border-bottom: 1px dashed coral;
        }
        .container{
            width: 800px;
            margin: 0 auto;
            background-color: rgb(220,220,220);
            padding: 40px;
            box-sizing: border-box;
        }
        .title{
            text-align: center;
        }
        .photo{
            width: 150px;
            border-radius: 50%;
            float: left;
        }
        .personInfo{
            float: left;
            margin: 0;
            display: flex;
            flex-direction: column;
            flex-wrap: wrap;
            font-size: 18px;
            font-weight: 600;
            height: 150px;
        }
        .personInfo>li{
            margin-right: 80px;
            height: 50px;
        }
        .personInfo>li>span{
            margin-right: 20px;
            letter-spacing: 2px;
        }
        .aspect{
            font-size: 22px;
            font-weight: 600;
            margin: 10px 0;
        }
        .edu>ul{
            display: flex;
            justify-content: space-between;
            padding: 0;
        }
        .edu>ul>li>span{
            margin-right: 10px;
            letter-spacing: 1px;
        }
        .edu>ul>li>span:nth-of-type(1){
            font-weight: 600;
        }
    </style>
</head>
<body>
    <div class="container" >
        <div class="header" style="overflow: hidden;">
            <h1 class="title" style="margin-top: 0;">Personal Resume</h1>
            <img class="photo" src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3681880960,455182084&fm=26&gp=0.jpg" alt="">
            <ul class="personInfo"></ul>
        </div>
        <div class="edu f1">
            <p class="aspect">教育背景</p>
        </div>
        <div class="skill f1">
            <p class="aspect">个人技能</p>
        </div>
        <div class="introduce f1">
            <p class="aspect">个人评价</p>
        </div>
    </div>
</body>
<script src="./node_modules/mockjs/dist/mock.js"></script>
<script src="./mock.js"></script>
<script>
    
    var xmlh = new XMLHttpRequest();
    xmlh.open('get','https://www.test.com');
    xmlh.send();
    xmlh.onreadystatechange = function(){
        if(xmlh.readyState == 4 && xmlh.status == 200){
            var data = JSON.parse(xmlh.responseText)
            console.log(data.personInfo);

            function createNode(item,node){
               var li = document.createElement('li')
               var span_key = document.createElement('span')
               var span_value = document.createElement('span')
               span_key.innerHTML = Object.keys(item)[0]
               span_value.innerHTML = Object.values(item)[0]
               li.appendChild(span_key)
               li.appendChild(span_value)
               node.appendChild(li)
            }
            var personInfo = document.getElementsByClassName('personInfo')[0];
            data.personInfo.forEach(function(item,index){
                createNode(item,personInfo)
            //    personInfo.appendChild(li)
            })

            var edu_ul = document.createElement('ul')
            data.edu.forEach(function(item,index){
                createNode(item,edu_ul)
                // edu_ul.appendChild(li)
                document.getElementsByClassName('edu')[0].appendChild(edu_ul)
            })

            var skill_p = document.createElement('p')
            skill_p.innerHTML = Object.values(data.skill[0])
            document.getElementsByClassName('skill')[0].appendChild(skill_p)

            var introduce_p = document.createElement('p')
            introduce_p.innerHTML = Object.values(data.introduce[0])
            document.getElementsByClassName('introduce')[0].appendChild(introduce_p)
        }
    }
</script>
</html>